﻿<UserControl x:Class="VS.MainModule.Views.LoginView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:df="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData /SampleData/LoginViewModelSampleData.xaml}"
    d:DesignHeight="300" d:DesignWidth="200"
    Name="uc">

    <Grid x:Name="LayoutRoot" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center">

        <df:DataForm 
            AutoGenerateFields="False" 
            MinWidth="200" 
            CommandButtonsVisibility="Cancel, Commit"
            AutoEdit="True"
            CurrentItem="{Binding}">
            <StackPanel>
                <df:DataField Label="Login">
                    <TextBox Text="{Binding Login, Mode=TwoWay}" />
                </df:DataField>
                <df:DataField Label="Password">
                    <PasswordBox Password="{Binding Password, Mode=TwoWay}" />
                </df:DataField>
            </StackPanel>
        </df:DataForm>

        <Border Visibility="{Binding ErrorsVisibility}" Background="Red" Opacity=".85" Margin="-50, 150, -50, -150">
            <ScrollViewer VerticalScrollBarVisibility="Auto" Background="Transparent" BorderThickness="0">
                <ListBox ItemsSource="{Binding Errors}">                    
                    <ListBox.Template>
                        <ControlTemplate>
                                <ItemsPresenter />
                        </ControlTemplate>
                    </ListBox.Template>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Foreground="White" FontWeight="Bold" MaxWidth="300" TextWrapping="Wrap" Text="{Binding Message}"/>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </ScrollViewer>
        </Border>

    </Grid>
</UserControl>
